const {Article} = require('../../model/article');

module.exports = async (req,res) => {

    //标识 表示当 前访问的页面
    req.app.locals.currentLink = 'article';

    const id = req.query.id
    // res.send(id)
    // return

    const users = await Article.findOne({_id: id});

    if(users) {
        res.render('admin/article-edit',{
            users: users,
            link: '/admin/article-modify?id=' + id,
            button: '修改'
        })
    }else {
        res.render('admin/article-edit',{
            link: '/admin/article-add',
            button: '提交'
        })
    }

    
}